#ifndef _xInMappingPort_H_
#define	_xInMappingPort_H_
/*------------------------------------------------------------
  2008/5/18 By YPC
   xMappingNode is of the new mapping node design (please see design document)
   There is no more VVnode and WVnode in this new design.
   "x" means X-man mapping node.
   a xMappingNode can accept abitrary kinds of connections 
   (from WOPs, VMs, collectors, or arithmetic operator
  --------------------------------------------------------------
*/

   

#include <vector>
#include "DIVA_VM.h"
#include "xLink.h"
#include "xParameterPack.h"
#include "vmLibrary.h"
using namespace std ;

class xLink ;
class xMappingNode ;
class xParameter ;
class xInMappingPort {

protected:
	string _name ;						// the name string read from vm description file
	string _type ;
	MNClass    _class ;						// CLASS_DEFAULT, CLASS_REQUIRED, CLASS_HIDDEN see vmlibrary.h for details
	string _defaultvalue ;
	xMappingNode * _node_parent ; // the mapping node this port belongs to
	xLink * _link ;
	MNCategory _category;				// CATEGORY_NAME, CATEGORY_POSITION, CATEGORY_COLOR, CATEGORY_SCALE, CATEGORY_ROTATION, CATEGORY_SIZE, CATEGORY_OTHER
	
public:
	inline xInMappingPort(xMappingNode *parent,
		                  string name, 
						  string type, 
						  MNClass    classp,
						  string defaultvalue,
						  MNCategory	 category) 
	{ _name = name ; _type = type ; _node_parent = parent; _class = classp ; _defaultvalue = defaultvalue ; _link = NULL ; _category = category; } 

	inline xInMappingPort(string type, xMappingNode *parent) {
		  _name = type ; 
		  _type = type ;
		  _class = CLASS_REQUIRED ;
		  _defaultvalue = "" ;
		  _link = NULL ;
		  _node_parent = parent; 
		  _category = CATEGORY_OTHER;
	}
	/** add a link to this port */

	inline string getName() { return _name ; }
	inline void   setName(string name) { _name = name ; }
	inline string getType() { return _type ; }
	inline void setCategory(MNCategory category) { _category = category; }
	inline MNCategory getCategory() { return _category; }

	inline MNClass getClass() { return _class ; }
	inline void setClass(MNClass classtype) { _class = classtype ; }

	inline xLink * getLink() { return _link ; }
	inline string getDefaultValue() { return _defaultvalue ; }
	inline void setDefaultValue(std::string value){this->_defaultvalue=value;}

	inline xMappingNode * getParent() { return _node_parent; }
	inline void add_link(xLink *p) { _link = p ; }
	inline void remove_link() { _link = NULL ; }

	xParameter toXParameter() ;
	int getIndexOfParent() ;
};
#endif 
